<template>
  <div v-loading="loading">
    <!-- <i-frame :src="openUrl" id="jimuReportFrame"></i-frame> -->
    <!-- <iframe :src="openUrl"></iframe> -->
    <iframe
      :src="openUrl"
      frameborder="0"
      scrolling="no"
      id="iframename"
      name="iframename"
      align="middle"
      style="margin-left: 5px"
    ></iframe>
  </div>
</template>
<script>
import { getToken } from "@/utils/auth";
// import iFrame from "@/components/iFrame/index";
export default {
  name: "Jimu",
  // components: { iFrame },
  data() {
    return {
      loading: true,
      // uploadUrl: import.meta.env.VITE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
      // 这里写暴露的统一的网关地址
      openUrl: "",

      // 生产环境
      // openUrl:
      //   "http://tms-gateway-crjz2027-jz-tms.crsems.crcloud.com/report/jmreport/list?token=" +
      //   getToken(),
      // 开发环境
      // openUrl: 'http://mes-gateway-resolinkpoc2023-et-mes.crsems.crcloud.com/report/jmreport/list?token='+getToken(),
    };
  },
  watch: {
     $route: {
      handler: function (route) {
         console.log(location.hostname, "===location.hostname")
         if (location.hostname == 'localhost' || location.hostname.indexOf('10.54.48.104')>-1) {
          this.openUrl = 'http://mes-gateway-resolinkpoc2023-et-mes.crsems.crcloud.com/report/jmreport/list?token='+getToken()
        } else {
          this.openUrl = "http://" + location.hostname + "/report/jmreport/list?token=" + getToken();
        }
         console.log(location.hostname,this.openUrl,"===location.hostname")
         this.loading = false;
      },
      deep:true,
  		immediate:true
    }
  },
  mounted() {
    const oIframe = document.getElementById("iframename");
    const deviceWidth = document.documentElement.clientWidth;
    const deviceHeight = document.documentElement.clientHeight;
    oIframe.style.width = "100%"; //数字是页面布局宽度差值
    oIframe.style.height = Number(deviceHeight) - 150 + "px";
    oIframe.style.height = Number(deviceHeight) - 150 + "px";
  },
};
</script>
